package com.acmen.easyapi.parse;

import com.acmen.easyapi.model.Dictionary;
import org.springframework.util.CollectionUtils;

import java.util.List;

public class NoteBuilder {
    public static String build(List<String> notes, List<Dictionary> dictionaries) {
        boolean multiRow = (notes == null?0:notes.size())+(dictionaries == null?0:1)>1;
        int idx = 1;
        StringBuffer stringBuffer = new StringBuffer();
        if(!CollectionUtils.isEmpty(notes)){
            if(multiRow){
                stringBuffer.append(idx+"、");
            }
            for(String note : notes){
                stringBuffer.append(note+"<br/>");
                idx ++;
            }
        }
        if(!CollectionUtils.isEmpty(dictionaries)){
            if(multiRow){
                stringBuffer.append(idx+"、");
            }
            stringBuffer.append("数据项说明：<br/>");
            stringBuffer.append("<div style=\"padding-left:10px;max-height:150px;overflow:auto;\">");
            for (Dictionary dict : dictionaries) {
                stringBuffer.append("<div  class=\"module\">"+dict.getValue()+":"+dict.getLabel()+"</div>");
            }
            stringBuffer.append("</div>");
        }
        return stringBuffer.toString();
    }
}
